/**
 * 
 */
package util;

import java.security.InvalidParameterException;

/**
 * 
 * @author LionBule 2011-6-24 下午02:38:07.
 */
public class PathUtil {
	public static int path2int(String h3, String h2, String h1, String h0){
		if(h3==null 
				|| h2==null
				|| h1==null
				|| h0==null
				|| h3.length()!=2
				|| h2.length()!=2
				|| h1.length()!=2
				|| h0.length()!=2)
			throw new InvalidParameterException();
		
		int b3 = Integer.parseInt(h3, 16);
		int b2 = Integer.parseInt(h2, 16);
		int b1 = Integer.parseInt(h1, 16);
		int b0 = Integer.parseInt(h0, 16);
		
		return path2int(b3, b2, b1, b0);
	}
	
	public static int path2int(int b3, int b2, int b1, int b0){
		return (int)((((b3 & 0xff) << 24) | ((b2 & 0xff) << 16) | ((b1 & 0xff) <<  8) | ((b0 & 0xff) <<  0)));		
	}
	
	public static String int2path(int v){
		return Integer.toHexString(v);
	}
}
